package com.niodata.dp.web;

import com.niodata.dp.util.StringUtil;
import com.niodata.dp.web.module.base.BaseController;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller("CustomController")
public class CustomController extends BaseController {

  @RequestMapping("/custom/login")
  public void customLogin(@RequestParam("session") String session, HttpServletResponse response)
        throws Exception {
    if (!StringUtil.isEmpty(session)) {
      Cookie cookies = new Cookie("SESSION", session);
      cookies.setMaxAge(1800);
      cookies.setPath("/");
      response.addCookie(cookies);
      response.sendRedirect("/#/filemanage/fileoverview");
    }
  }
}
